<div class="form-container">
	<form id="form">
		<table class="tableform">
			<tr>
				<th style="width:70px;">所属公司：</th>
				<td>
					<input id="company" name="company_id" class="easyui-validatebox" type="text" style="width: 188px; height:25px;" />
				</td>
			</tr>
			<tr>
				<th style="width:70px;">所属部门：</th>
				<td>
					<input id="dept" name="dept_id" class="easyui-validatebox" type="text" style="width: 188px; height:25px;" />
				</td>
			</tr>
			<tr style="display:none">
				<td>
					<input type="hidden" name="user_ids" id="user_ids"/>
				</td>
			</tr>
		</table>
	</form>
</div>

<script>
	var $company, $dept;
	$(function(){
		$company = $("#company").combotree({
			url: "${ctx}/manager/base/company/treegrid",  method: "GET",
			idFiled:'companyId', editable: false, required: true, lines:true, autoShowPanel: false,
			url : "${ctx}/manager/base/company/treegrid",
			editable: false, lines:true, method: "GET",
			onChange: function(newValue, oldValue) {
				if(undefined != oldValue && null != oldValue) {
					$dept.combotree({
						url: "${ctx}/manager/base/dept/treegrid/"+newValue
					});
				}
            },
            onLoadSuccess: function(node,data) {
				$company.combotree("setValue", data[0].id);
			}
		});
		$dept = $("#dept").combotree({
			method: "GET", idFiled:'pid', editable: false, required:false, lines:true, autoShowPanel: false
		});
	});
	
	//提交表单数据
	var submitNow = function($d, $dg, flag) {
		$.post("${ctx}/manager/base/user/changeDeptBatch", $("#form").form("getData"), function(result) {
			if (result.status) {
				$dg.datagrid('reload');$.messager.alert("错误", result.message, "info");$.easyui.loaded();
				if(flag==undefined||flag==false){$d.dialog("close") ;}
			} else {
				$.easyui.loaded();$.messager.alert("错误", result.message, "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	};
	
	//验证表单
	var submitForm = function($d, $dg, flag) { 
		if($('#form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d, $dg, flag) ;
		}
	};
</script>

